#pragma once

#include "device_impl.h"

#ifdef BLU_EXPORT
#undef BLU_EXPORT
#define BLU_EXPORT __declspec(dllexport)
#else
#define BLU_EXPORT __declspec(dllimport)
#endif

namespace blu
{
	namespace impl
	{
		struct implAccess
		{
			template <typename Ty>
			static auto& getImpl(Ty &val)
			{
				return val._impl;
			}

			template <typename Ty, typename Impl>
			static Ty makeThroughImpl(Impl &&impl)
			{
				Ty v(std::forward<Impl>(impl));
				return std::move(v);
			}
		};

		template <typename DerivedGLObject>
		struct DerivedGLObjectTraits
		{

		};

		template <typename DerivedGLObject>
		class GLObjectBase
		{
		private:
			typedef DerivedGLObjectTraits<DerivedGLObject> MyTraits;
		protected:
			::GLuint _handle;
		public:
			typedef ::GLuint handle_type;

			GLObjectBase(Device &)
				:_handle(MyTraits::construct())
			{

			}

			~GLObjectBase()
			{
				if (_handle)
				{
					MyTraits::deconstruct(_handle);
					_handle = 0;
				}
			}

			::GLuint handle() const
			{
				return _handle;
			}

			static ::GLuint valueless_handle()
			{
				return 0;
			}

			void pushAndMakeCurrent()
			{

			}

			void popCurrent()
			{

			}
		};
	}
}